#include <vector>

using std::vector;

class Solution {
public:
    void setZeroes(vector<vector<int>>& matrix) {
        int m = matrix.size();
        int n = matrix[0].size();
        vector<int> v1(m, 0);
        vector<int> v2(n, 0);
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (matrix[i][j] == 0) {
                    v1[i] = v2[j] = 1;
                }
            }
        }
        for (int i = 0; i < m; i++) {
            if (v1[i] == 1) {
                matrix[i].assign(n, 0);
            }
        }
        for (int j = 0; j < n; j++) {
            if (v2[j] == 1) {
                for (int i = 0; i < m; i++) {
                    matrix[i][j] = 0;
                }
            }
        }
    }
};